<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/custom-theme/jquery-ui.custom.min.css" />	
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
	<script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.form.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/json2.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.validate.min.js"></script>
	<script type="text/javascript" src="<s:url value="/resources"/>/js/messages_zh.js"></script>
	
	<style type="text/css">
html, body {
	margin: 0;			 
	padding: 0;	 
    font-size: 85%;
}
#tab{
	width:99%;	
	padding:0 2px 3px 2px;
	margin:0;
	float:left;
}
#tab h1{
	display:block;
	width:95%;
	height:45px;	
	float:center;
	text-align: center;
	padding-top:5px;
}
#tab h1 span{
	width:250px;
	font:bold 26px/55px Arial, Helvetica, sans-serif;
	color:#fff;
	background-color:#fff;
	display:block;
}
.textbox
{
	width:90px;
	border:#000 1px solid;
}
.textboxs
{
	width:70px;
	border:#000 1px solid;
}
.longtextbox
{
	width:180px;
	border:#000 1px solid;
}
.longtextbox1 {
	width: 180px;
	border: #000 1px solid;
	background-color: #ddd;
}
.shorttextbox
{
	width:50px;
	border:#000 1px solid;
}
.shorttextbox1
{
	width:50px;
	border:#000 1px solid;
	background-color:#ddd;
}
.textarea
{
    overflow:auto;	
	border:#000 1px solid;
		
}
.textarea1 {
	overflow: auto;
	border: #000 1px solid;
	background-color: #ddd;
}
.select div {
  border:1px solid #000;
  float: left;
}
label{ display:block; }
fieldset { padding:0; border:0; margin-top:25px; }
label.error {  
        color: red;/*错误信息的颜色*/  
    }  
input.error {  
        border:1px dotted red;/*输入错误的输入框的边框样式*/  
    }		
	
	</style>
<script type='text/javascript'>    

    function loadHttk(){
       var url = "<s:url value="/"/>/common/loadHttk";
       $.post(url,function(data){       
       var json = eval('(' + data + ')');
       $( "#tkjson").val(data);
       $( "#httk").children().remove();       
       var dtable = document.getElementById("httk");
       for(var i=0; i<json.length; i++){
       jydzObj=json[i];
       var elTr = dtable.insertRow( -1 );
       var tkTd = elTr.insertCell( -1 );
       var tx ="<span id=\"tkh"+i+"\" >"+jydzObj.xh+"</span>";
       tkTd.innerHTML = tx;
       var idTd = elTr.insertCell( -1 );
       idTd.width="400px";
       var sx ="<span id=\"sx"+i+"\" >"+jydzObj.biaot+"</span>";
       idTd.innerHTML = sx;
       var jfTd = elTr.insertCell(-1);
       var jfyq="<textarea cols=\"142\" rows=\"2\" class=\"textarea\" >"+jydzObj.neir+"</textarea>";     
       jfTd.innerHTML=jfyq;
       }
       });
    }
    
    function changeTabForHttk(vvalue){ 
        //alert(vvalue);         
       var url = "<s:url value="/"/>/common/changeHttk?mbId="+vvalue;
       $.post(url,function(data){
       var json = eval('(' + data + ')');
       $( "#tkjson").val(data);
       $( "#httk").children().remove();       
       var dtable = document.getElementById("httk");
       for(var i=0; i<json.length; i++){
       jydzObj=json[i];
       var elTr = dtable.insertRow( -1 );
       var tkTd = elTr.insertCell( -1 );
       var tx ="<span id=\"tkh"+i+"\" >"+jydzObj.xh+"</span>";
       tkTd.innerHTML = tx;
       var idTd = elTr.insertCell( -1 );
       idTd.width="400px";
       var sx ="<span id=\"sx"+i+"\" >"+jydzObj.biaot+"</span>";
       idTd.innerHTML = sx;
       var jfTd = elTr.insertCell(-1);
       var jfyq="<textarea cols=\"142\" rows=\"2\" class=\"textarea\" >"+jydzObj.neir+"</textarea>";     
       jfTd.innerHTML=jfyq;
       }
       });
    }
    
    function changeTabForJsdw(vvalue,dwlx){
        var url = "<s:url value="/"/>/common/changeJsdw";
        $.post(url,{qiyid:vvalue,qiylx:dwlx},function(data){ 
          var data = eval('(' + data + ')'); 
           if(dwlx=='1'){
              $("#szs").val(data.chumdwjsrdz);
              $("#sfddbr").val(data.chumdwjsrfddbr);
              $("#swtdlr").val(data.chumdwjsrwtdlr);
              $("#sdh").val(data.chumdwjsrdh);
              $("#scz").val(data.chumdwjsrcz);
              $("#syb").val(data.chumdwjsryzbm);
              $("#skhyh").val(data.chumdwjsrkhyh);
              $("#szh").val(data.chumdwjsrzh);
              $("#sdjh").val(data.chumdwjsrnsrdjh);
              $("#cmdwjsrmc").val( $("#chumdwjsrbm").find("option:selected").text()); 
           }else{
              //alert(data.maisdwjsrdz);
              $("#bzs").val(data.maisdwjsrdz);
              $("#bfddbr").val(data.maisdwjsrfddbr);
              $("#bwtdlr").val(data.maisdwjsrwtdlr);
              $("#bdh").val(data.maisdwjsrdh);
              $("#bcz").val(data.maisdwjsrcz);
              $("#byb").val(data.maisdwjsryzbm);
              $("#bkhyh").val(data.maisdwjsrkhyh);
              $("#bzh").val(data.maisdwjsrzh);
              $("#bdjh").val(data.maisdwjsrnsrdjh);
              $("#msdwjsrmc").val( $("#maisdwjsrbm").find("option:selected").text()); 
           }
        
        });       
    }    

    function loadMonthCss(){
    var sDate=$("#cDate").val();
    sDate = sDate.substring(5,7);
    if(sDate=='01'){
    replaseCss($("#jan0"));
    replaseCss($("#feb0"));
    replaseCss($("#mar0"));
    replaseCss($("#apr0"));
    replaseCss($("#may0"));
    replaseCss($("#jun0"));
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='02'){
    replaseCss($("#feb0"));
    replaseCss($("#mar0"));
    replaseCss($("#apr0"));
    replaseCss($("#may0"));
    replaseCss($("#jun0"));
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='03'){
    replaseCss($("#mar0"));
    replaseCss($("#apr0"));
    replaseCss($("#may0"));
    replaseCss($("#jun0"));
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='04'){
    replaseCss($("#apr0"));
    replaseCss($("#may0"));
    replaseCss($("#jun0"));
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='05'){    
    replaseCss($("#may0"));
    replaseCss($("#jun0"));
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='06'){
    replaseCss($("#jun0"));
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='07'){
    replaseCss($("#jul0"));
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='08'){
    replaseCss($("#aug0"));
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='09'){
    replaseCss($("#sep0"));
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='10'){
    replaseCss($("#oct0"));
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));    
    }
    if(sDate=='11'){
    replaseCss($("#nov0"));
    replaseCss($("#dec0"));
    }
    if(sDate=='12'){
    replaseCss($("#dec0"));
    }   
    }
    
    function replaseCss(d){    
    d.removeClass("shorttextbox1");
    d.addClass("shorttextbox");
    d.removeAttr("readonly");
    }
    
    function recoverCSs(d){
    d.val("");
    d.removeClass("shorttextbox");
    d.addClass("shorttextbox1");
    d.attr("readonly","readonly"); 
    }

    
    function loadShdwData(i,msrid){
    var url = "htgl/findShdwList.action?msrId="+msrid;    
      $.post(url,function(data){ 
        var projects = eval('(' + data + ')'); 
        //alert(projects);
       $( "#shr"+i).autocomplete({
			minLength:2,
			source:projects,			
            select: function( event, ui ) {
            //alert(ui.item.label);	
				$( "#shr"+i ).val( ui.item.label );							
				$( "#shrid"+i ).val( ui.item.shouhdwbm );						
				return false;

			}
		});
    });
    }
    
    
    function loadJsdwForCombox(){
        var url = "<s:url value="/"/>/common/loadJsdw";
       $.post(url,function(data){
            var json = eval('(' + data + ')'); 
            for(var i=0;i<json.length;i++){            
            $("#maisdwjsrbm").append("<option value='"+json[i].sysid+"'>"+json[i].mingch+"</option>");
            }
            });
    }
    
    function loadJydwData(){
        var url = "<s:url value="/"/>/common/loadCmr";
        var dwbm =${sysuser.orgid};
        $.post(url,function(data){
            var json = eval('(' + data + ')');            
            $("#cmrbm").empty();
            if(json.length>0){
            $("#cmrbm").append("<option value="+json[0].chumdwbm+" seleted>"+json[0].chumdwmc+"</option>");
        $("#maisr").val(json[0].chumdwmc);
        $("#zs").val(json[0].chumdwdz);
        $("#fddbr").val(json[0].chumdwfddbr);
        $("#wtdlr").val(json[0].chumdwwtdlr);
        $("#dh").val(json[0].chumdwdh);
        $("#cz").val(json[0].chumdwcz);
        $("#yb").val(json[0].chumdwyzbm);
        $("#khyh").val(json[0].chumdwkhyh);
        $("#zh").val(json[0].chumdwzh);
        $("#djh").val(json[0].chumdwnsrdjh);
        
        for(var i=1;i<json.length;i++){
        //alert(projects[i].name);
        $("#cmrbm").append("<option value='"+json[i].chumdwbm+"'>"+json[i].chumdwmc+"</option>");
        }
        var qiyid=json[0].chumdwbm;
         if(dwbm==qiyid){
            $("#baoddwlx").val('1');
            }else{
            $("#baoddwlx").val('2');
            }
        
        }
        
        $("#bzs").val('${jydw.tongxdz}');
        $("#bfddbr").val('${jydw.faddbr}');
        $("#bwtdlr").val('${jydw.lianxr}');
        $("#bdh").val('${jydw.qiydh}');
        $("#bcz").val('${jydw.qiycz}');
        $("#byb").val('${jydw.qiyyb}');
        $("#bkhyh").val('${jydw.jiesfzh}');
        $("#bzh").val('${jydw.jiesyhzh}');
        $("#bdjh").val('${jydw.shuiwdjzhgs}');
        
       
        });
    }
    
    function changeTabForCmr(val){ 
      var url = "<s:url value="/"/>/common/changeCmr";     
      var dwbm =${sysuser.orgid}; 
      $.post(url,{qiyid:dwbm},function(data){
            var json = eval('(' + data + ')');
            $("#maisr").val(json[0].danwmc);
            $("#zs").val(json[0].zhus);
            $("#fddbr").val(json[0].faddbr);
            $("#wtdlr").val(json[0].weitdlr);
            $("#dh").val(json[0].dianh);
            $("#cz").val(json[0].chuanz);
            $("#yb").val(json[0].youzbm);
            $("#khyh").val(json[0].kaihyh);
            $("#zh").val(json[0].yinhzh);
            $("#djh").val(json[0].nasrdjh);
            $("#cmrbm").val(val);
            if(dwbm==val){
            $("#baoddwlx").val('1');
            }else{
            $("#baoddwlx").val('2');
            }
            });
      }
   
    $(function(){        
        loadMonthCss();
        loadJydwData();
        loadJsdwForCombox();
        loadHttk();                
        $("#but1").button();
        $("#but2").button();
        $("#but3").button();
        $("#jsdnr").button();
        $("#jsdnr1").button();
        $("#jsdnr1").hide();
        $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);   
        $( "#kssj" ).datepicker($.datepicker.regional[ "zh-CN" ]);
        $( "#jssj" ).datepicker($.datepicker.regional[ "zh-CN" ]);     
		$( "#pzgg" ).dialog({
		    autoOpen: false,
		    modal: true
		   }); 
		tj();   
		jsdxxShow();  
		$("#jsdnr1").click(function(){
		jsdxxHide();		
		});
		$("#jsdnr").click(function(){
		jsdxxShow();		
		}); 
		//$( document ).tooltip();
		$( document ).tooltip({
      position: {
        my: "left top",
        at: "right top",
        using: function( position, feedback ) {
        $( this ).css( position );
          $( "<div>" )
            .addClass( "arrow" )
            .addClass( feedback.vertical )
            .addClass( feedback.horizontal )
            .appendTo( this );
        }
      }

    });
    });
    
    
	
	function tj(){		
	/**  
     * 自定义验证规则——增加对select的验证  
     */  
    $.validator.addMethod(    
        "selectNone", 
        function(value, element)
        {   
            if (value == "-1") 
            {    
                return false;    
            }    
            else    
            {   
                return true;    
            }   
        },    
        "必须选择一项" 
    );   
	
	$("#form1").validate({
	       rules: {
	       "shouhdwmc":"required", 
	       "pinzgg":"required",	            
	       "hetxs":{
	       selectNone:true
	       },
	       "hangy":{
	       selectNone:true
	       },	       	       
	       "shul":{
	       required: true, 
	       digits:true,
	       range:[0,9999999]
	       },      
	       "jiag":{
	        required: true, 
	        number:true,
	        range:[0,3000]
	       }
	       },
		   messages: {
		   "hetxs":"请选择合同形式",
	       "hangy":"请选择隶属行业",
		   "pinzgg":"请选择品种规格",
		   "shul":{
	       required: "请输入数量", 
	       digits:"请输入整数",
	       range:jQuery.validator.format("请输入一千万吨之内的数")
	       },
		   "jiag":{
		    required:"请输入价格",
		    number:"请输入合法数字",
		    range:jQuery.validator.format("请输入0和3000之间的数")
		   }
		   
		   }
		   });
		   
		   $("#but1").click(function(){
		    if($("#form1").valid()){
		       var kssj =$("#kssj").val();
		       var jssj =$("#jssj").val();		       		       
		       var cDate=$("#cDate").val();
               var cNf = cDate.substring(0,4);              
               var nf = $("#nianf").val();               
		       var eDate =$("#eDate").val();
		       var flag = true;
		       var msg = "";
		        if(document.getElementById("shrid0").value==""){
		           msg ="请选择收货单位";
		           flag =  false;
		        }		        
		        if(document.getElementById("mzbm0").value=="-1"){
		           msg ="请点击品种规格后选择煤种";
		           flag =  false;
		        }
		        if(document.getElementById("pzbm0").value=="-1"){
		           msg ="请点击品种规格后选择品种";
		           flag =  false;
		        }
		        if(document.getElementById("daozbm").value==""){
		           msg = "请选择到站";
		           flag =  false;
		        }
		        if(nf==cNf){
		            if(comptime(cDate,kssj)){
		               msg ="合同有效期:起始日期不能小于当天";
		               flag =  false;
		            }
		            if(comptime(jssj,eDate)){
		               msg ="合同有效期:结束日期不能大于下月末最后一天";
		               flag =  false;
		            }
		        }
		        
		        if(comptime(kssj,jssj)){
		           msg ="合同有效期:结束日期必须大于起始日期";
		           flag =  false;
		        }
		        if(parseFloat(document.getElementById("shul0").value)!=parseFloat(GetYueZJ())){
		          msg ="报单总数量和分月数量不等,请重新填写";
		          flag = false;
		        }
		        
		        if(flag){
		        var url = "<s:url value="/"/>/jjjy/saveJjbd";
		        //alert(url);
		         $("#form1").ajaxSubmit({
		              url:url,
		              type:'post',
		              success:function(data){
		              var json =eval('(' + data + ')');
					    if(json.result==1){
					    alert("保存成功！");
					    window.returnValue=1;
                        window.close();					   
					   }else{
					    alert("保存失败！");
					    //window.returnValue=1;
                        //window.close();
					   }
		              }
		         });	
		        }else{
		          alert(msg);
		        }
		        	       
		        
		        }
		       });
		       
		    $("#but2").click(function(){
		    if($("#form1").valid()){
		       var kssj =document.getElementById("kssj").value;
		       var jssj =document.getElementById("jssj").value;		       
		       var cDate=$("#cDate").val();
		       var eDate =$("#eDate").val();
		       var flag = true;
		       var msg = "";
		        if(document.getElementById("shrid0").value==""){
		           msg ="请选择收货单位";
		           flag =  false;
		        }		        
		        if(document.getElementById("mzbm0").value=="-1"){
		           msg ="请点击品种规格后选择煤种";
		           flag =  false;
		        }
		        if(document.getElementById("pzbm0").value=="-1"){
		           msg ="请点击品种规格后选择品种";
		           flag =  false;
		        }
		        if(document.getElementById("daozbm").value==""){
		           msg = "请选择到站";
		           flag =  false;
		        }
		        if(comptime(cDate,kssj)){
		           msg ="合同有效期:起始日期不能小于当天";
		           flag =  false;
		        }
		        if(comptime(jssj,eDate)){
		           msg ="合同有效期:结束日期不能大于下月末最后一天";
		           flag =  false;
		        }
		        if(comptime(kssj,jssj)){
		           msg ="合同有效期:结束日期必须大于起始日期";
		           flag =  false;
		        }
		        
		        if(parseFloat(document.getElementById("shul0").value)!=parseFloat(GetYueZJ())){
		          msg ="报单总数量和分月数量不等,请重新填写";
		          flag = false;
		        }
		        
		        if(flag){
		       var url = "<s:url value="/"/>/jjjy/saveAndSubmitJjbd";
		         $("#form1").ajaxSubmit({
		              url:url,
		              type:'post',
		              success:function(data){
		              var json =eval('(' + data + ')');
					    if(json.result==1){
					    alert("提报成功！");
					    window.returnValue=1;
                        window.close();					   
					   }else{
					    alert("保存失败！");
					    //window.returnValue=1;
                        //window.close();
					   }
		              }
		         });	
		        }else{
		          alert(msg);
		        }
		        	       
		        
		        }
		       });
	     
	}
	
	
		
		
	
	function txtzjl_onblur(i) { 
	     if ($("#shul"+i).val() != "") {
	            var myDate = new Date();
	            var yf = myDate.getMonth()+1;
                var zjsl = parseFloat($("#shul"+i).val());
                var yuesl = zjsl / (12-yf+1);
                var intyue = parseInt(yuesl);
                var syysl = intyue * (11-yf+1);
                var srysl = zjsl - syysl;
                SetYueZJ(i,intyue, srysl);
                return;
            }
            SetYueZJ(i,0, 0); 
	     
            
        }

        function SetYueZJ(i,yuesl, srysl) {
            if(yuesl==0){
            $("#shul"+i).val(yuesl)
            }
            var myDate = new Date();
            var yf=myDate.getMonth()+1;            
            for (var j=1;j<13;j++){
            if(j>=yf){
      	      $("input[name='gml"+j+"']").val(yuesl) ;
      	      }
            }            
            $("#dec"+i).val(srysl);            
        }  
        
     function txtyuesl_onblur(i) {            
            
            var temp = GetYueZJ(i);
            if (isNaN(temp)) {
                $("#shul"+i).val(0);                
            }
            else {
                $("#shul"+i).val(temp);                
            }

        }

        function GetYueZJ(i) {                  
            var yue1 =parseFloat($("#jan0").val()==''?0:$("#jan0").val());            
            var yue2 = parseFloat($("#feb0").val()==''?0:$("#feb0").val());
            var yue3 = parseFloat($("#mar0").val()==''?0:$("#mar0").val());
            var yue4 = parseFloat($("#apr0").val()==''?0:$("#apr0").val());
            var yue5 = parseFloat($("#may0").val()==''?0:$("#may0").val());
            var yue6 = parseFloat($("#jun0").val()==''?0:$("#jun0").val());
            var yue7 = parseFloat($("#jul0").val()==''?0:$("#jul0").val());
            var yue8 = parseFloat($("#aug0").val()==''?0:$("#aug0").val());
            var yue9 = parseFloat($("#sep0").val()==''?0:$("#sep0").val());
            var yue10 = parseFloat($("#oct0").val()==''?0:$("#oct0").val());
            var yue11 = parseFloat($("#nov0").val()==''?0:$("#nov0").val());
            var yue12 = parseFloat($("#dec0").val()==''?0:$("#dec0").val()); 

            var yuezj = yue1 + yue2 + yue3 + yue4 + yue5 + yue6 + yue7 + yue8 + yue9 + yue10 + yue11 + yue12;            
            return yuezj;
        }
     
     function jsdxxHide(){
     $("#jsdnr1").hide();
     $("#jsdnr").show();
        $.each($("#bjsdnr tr"), function(i){     
         if(i > 0){        
           this.style.display = 'none';    
          }   
        }); 
        $.each($("#bjsdnr1 tr"), function(i){     
         if(i > 0){        
           this.style.display = 'none';    
          }   
        }); 
        $.each($("#sjsdnr tr"), function(i){     
         if(i > 0){        
           this.style.display = 'none';    
          }   
        }); 
        $.each($("#sjsdnr1 tr"), function(i){     
         if(i > 0){        
           this.style.display = 'none';    
          }   
        });   
     }  
     
     function jsdxxShow(){
     $("#jsdnr").hide();
     $("#jsdnr1").show();
     $.each($("#bjsdnr tr"), function(i){     
         if(i > 0){        
           this.style.display = 'block';    
         }   
       });
     $.each($("#sjsdnr tr"), function(i){     
         if(i > 0){        
           this.style.display = 'block';    
         }   
       }); 
       $.each($("#bjsdnr1 tr"), function(i){     
         if(i > 0){        
           this.style.display = 'block';    
         }   
       });
     $.each($("#sjsdnr1 tr"), function(i){     
         if(i > 0){        
           this.style.display = 'block';    
         }   
       });
     } 
     
     function comptime(time1, time2) {
        var d1 = new Date(time1.replace(/-/g, "/"));
        var d2 = new Date(time2.replace(/-/g, "/"));
        if(Date.parse(d1) - Date.parse(d2) > 0)
                return true;
        else
                return false;
}

     function changeTabForYxq(vvalue){
     var flag ="0";
       if(vvalue==2013){
       $( "#kssj").val("2013-01-01");
       $( "#jssj").val("2013-12-31");
       flag="0";
       }
       else if(vvalue==2014){
       $( "#kssj").val("2014-01-01");
       $( "#jssj").val("2014-12-31");
       flag="1";
       }
       else if(vvalue==2015){
       $( "#kssj").val("2015-01-01");
       $( "#jssj").val("2015-12-31");
       flag="1";
       }
       if(flag=="0"){
       recoverCSs($("#jan0"));
       recoverCSs($("#feb0"));
       recoverCSs($("#mar0"));
       recoverCSs($("#apr0"));
       recoverCSs($("#may0"));
       recoverCSs($("#jun0"));
       recoverCSs($("#jul0"));
       recoverCSs($("#aug0"));
       recoverCSs($("#sep0"));
       recoverCSs($("#oct0"));
       recoverCSs($("#nov0"));
       recoverCSs($("#dec0"));    
       loadMonthCss();
       }else{
       replaseCss($("#jan0"));
       replaseCss($("#feb0"));
       replaseCss($("#mar0"));
       replaseCss($("#apr0"));
       replaseCss($("#may0"));
       replaseCss($("#jun0"));
       replaseCss($("#jul0"));
       replaseCss($("#aug0"));
       replaseCss($("#sep0"));
       replaseCss($("#oct0"));
       replaseCss($("#nov0"));
       replaseCss($("#dec0"));
       }
    }
    
    function clickPzgg(i){
     openwindow('<s:url value="/"/>/htgl/findZlzbView','500','700');
    }
     
    function clickDaoz(){
     openwindow('<s:url value="/"/>/htgl/findDaozView','300','400');
    }
    
    function openwindow(url,sheight,swidth){
       var winoption ="dialogHeight:"+sheight+"px;dialogWidth:"+ swidth +"px;status:yes;scroll:yes;resizable:yes;center:yes";
       window.showModalDialog(url,window,winoption);
    }
	
	</script>

  </head>
  
  <body>

<div id="tab">
<h1>&nbsp;招  标  报 单</h1>
<form name="form1" id="form1">
<table id="list_search" cellpadding="0" cellspacing="0" border="0">
        <tr>
        	<td> 
            	出卖人（销方）: 
            </td>
            <td>
            <input type="text" style="color:'#C0C0C0'" class="longtextbox1" readOnly="true"/>            
            <input type="hidden" name="maimlx" value="5">
            <input type="hidden" name="dongzlx" value="5">
            <input type="hidden" name="dongzbm" value="26">
            <input type="hidden" name="baoddwid" value="${jydw.qiydm}">
            
            </td>
            <td>产地:</td>
            <td>
            <input id="hetlrbh" type="text" class="longtextbox1" readOnly="true"/>
            <span id="htSpan" ></span>
            <input type="hidden" id="isRepeat" value="0">
            <input type="hidden" id="isZgdw" value="0">
            </td>
            <td>  
                                             发站:
            </td>
            <td>
            	<input type="text" style="color:'#C0C0C0'" class="longtextbox1" readOnly="true"/>                
                
            </td> 
        </tr>
        
		<tr>
        	<td>
            	买受人（购方）:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>
            </td>
            <td>
            	<div class="select"><div>
            	<select id="cmrbm" name="baoddw" style="width:180px;" onchange="changeTabForCmr(this.value)" >           	
            	</select>            	
            </div></div>
            <input type="hidden" id="baoddwlx" name="baoddwlx">	
            </td>            
            <td>煤炭用途:<span
						style="color: red;font-size:16px;vertical-align:middle;">*</span>
					</td>
					<td>
						<div class="select">
							<div>
								<select name="meityt" style="width:180px" >
									<option value="-1" selected>==请选择==</option>
									<c:forEach var="meyt" items="${meityt}">
										<option value="${meyt.diccode}">${meyt.dicname}</option>
									</c:forEach>
								</select>
							</div>
						</div>
			</td>
            <td>
                                          到站:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>
            </td>
            <td>            	 
            	<input id="daozmc" type="text" name="daozmch" class="longtextbox" onclick="clickDaoz();"/>                
                <input type="hidden" id="daozbm" name="fadzbm"> 
                <input type="hidden" id="zyx" name="zhuanyx">
                <input type="hidden" id="zzgid" name="huangzgid">
                <input type="hidden" id="zzgmc" name="huangzgmc">
                <input type="hidden" id="jxgid" name="zhongdgid">
                <input type="hidden" id="jxgmc" name="zhongdgmc">
            </td>            
        </tr>
        
        <tr>
        	<td>
            	合同形式:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>
            </td>
            <td>
            	<div class="select"><div>
            	
            	<select id="hetxs" name="hetxs" style="width:180px">
            	  <option value="-1" selected>==请选择==</option>
                  <option value="3">省内铁路</option>
                  <option value="4">铁路出省</option> 
                 </select>
            	</div></div>
            </td>
            <td>
            	价格类型:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>                
            </td>
            <td>
            	<div class="select"><div>
            	<select id="jiaglx" name="jiaglx" style="width:180px">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="jglx" items="${jglxList}">
                   <option value="${jglx.diccode}">
                   ${jglx.dicname}
                   </option>
                   </c:forEach>
                 </select>
            	</div></div>
            </td>
            <td>
                                        隶属行业:<span style="color: red;font-size:16px;vertical-align:middle;">*</span>                       
            </td>
            <td>            	 
            	<div class="select"><div>
            	<select id="lis" name="lis" style="width:180px">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="hy" items="${hyList}">
                   <option value="${hy.diccode}">
                   ${hy.dicname}
                   </option>
                   </c:forEach>
                 </select>	
            	</div></div>
            </td>            
        </tr>
       
       <tr>
        	<td>
            	发货单位:
            </td>
            <td>
                <input type="text" style="color:'#C0C0C0'" class="longtextbox1" readOnly="true"/>
            </td>            
			<td>交收方式:</td>
            <td><input type="text" class="longtextbox1" readOnly="true"/></td>
            <td>交收地点:</td>
            <td><input type="text" class="longtextbox1" readOnly="true"/></td>
                        
        </tr>
       
        <tr><td colspan="6" style="padding-top:5px;">一、收货人名称、品种规格、数量、单价 </td></tr>
       <tr>
        	<td colspan="6" style="padding:1px;">
            <table id="changdi" align="center" cellpadding="0" cellspacing="0" class="content_gridview" border="1">
            <thead>
            <tr>
              <th rowspan="3">收货人名称<span style="color: red;font-size:16px;vertical-align:middle;">*</span></th>
              <th rowspan="3">品种规格<span style="color: red;font-size:16px;vertical-align:middle;">*</span></th>
              <th rowspan="3">质量指标</th>
              <th rowspan="3">价格<br/>(元/吨)<span style="color: red;font-size:16px;vertical-align:middle;">*</span></th>
              <th colspan="13">交（提）货时间、煤量（吨）<span style="color: red;font-size:16px;vertical-align:middle;">*</span></th>              
            </tr>
            <tr>
              <th rowspan="2">全年合计<span style="color: red;font-size:16px;vertical-align:middle;">*</span><br><a href="#" onclick="txtzjl_onblur(0);" style="text-decoration:none;cursor: hand"><img src="<s:url value="/resources"/>/images/pinf.gif" border=0 alt="平分" align= "absmiddle" height="18"  width="18"></a>&nbsp;&nbsp;<a href="#" onclick="SetYueZJ(0,0,0);" style="border:0px;text-decoration:none;cursor: hand"><img src="<s:url value="/resources"/>/images/qinl.gif"  border=0 alt="清零" align="absmiddle" height="18"  width="18"></a></th>
              <th colspan="3">一季度</th>
              <th colspan="3">二季度</th>
              <th colspan="3">三季度</th>
              <th colspan="3">四季度</th>
            </tr>
            <tr>
              <th>1</th>
              <th>2</th>
              <th>3</th>
              <th>4</th>
              <th>5</th>
              <th>6</th>
              <th>7</th>
              <th>8</th>
              <th>9</th>
              <th>10</th>
              <th>11</th>
              <th>12</th>
            </tr>
          </thead>
            <tbody>
                <tr>
                    <td>
                    <textarea id="shr0" cols="15" rows="3" class="textarea" title="请录入至少两个汉字关键字选择收货人">${jydw.qiyqc}</textarea>                    
                    <input id="shrid0" type="hidden" name="sfahdw" value="${jydw.qiyid}"/>
                    </td>
                    <td>
                    <textarea id="fh0" cols="12" rows="3" name="pinzgg" class="textarea" readonly="readonly" onclick="clickPzgg(0);" title="请鼠标点击后操作"></textarea>                    
                    <input type="hidden" id="mzbm0" name="meiz">
                    <input type="hidden" id="mzmc0">
                    <input type="hidden" id="pzbm0" name="pinz">
                    <input type="hidden" id="pzmc0">
                    </td>
                    <td>
                    <textarea id="zlzb0" cols="30" rows="3" class="textarea" name="zhilzb"></textarea>                    
                    <input type="hidden" id="zlzbfz0" name="zhilzbfzbm">
                    <input type="hidden" id="zbAry" name="zb">
                    <input type="hidden" id="ppname">
                    <input type="hidden" id="ppid" name="pinp">
                    </td>
                    <td><input id="jiag0" type="text" class="shorttextbox" name="jiag"  title="请输入0和3000之间的数"/></td>
                    <td><input id="shul0" type="text" class="textboxs" name="shul" title="请输入一千万吨之内的数"></td>
                    <td><input id="jan0" type="text" class="shorttextbox1" name="gml1" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="feb0" type="text" class="shorttextbox1" name="gml2" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="mar0" type="text" class="shorttextbox1" name="gml3" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="apr0" type="text" class="shorttextbox1" name="gml4" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="may0" type="text" class="shorttextbox1" name="gml5" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="jun0" type="text" class="shorttextbox1" name="gml6" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="jul0" type="text" class="shorttextbox1" name="gml7" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="aug0" type="text" class="shorttextbox1" name="gml8" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="sep0" type="text" class="shorttextbox1" name="gml9" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="oct0" type="text" class="shorttextbox1" name="gml10" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="nov0" type="text" class="shorttextbox1" name="gml11" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>
                    <td><input id="dec0" type="text" class="shorttextbox1" name="gml12" readonly onkeypress="if( event.keyCode == 13 ) {txtyuesl_onblur(0);}" onKeyUp="this.value=this.value.replace(/\D/g,'');"></td>                    
                </tr> 
            </tbody>
            </table>
            </td>
        </tr>
        <tr>
        	
            <td >
                                        条款模板:
            </td>
            <td colspan="5">            	 
            	<div class="select"><div>            	
            	<select style="width:180px" onchange="changeTabForHttk(this.value)">
            	<option value="-1" selected>==请选择==</option>
                   <c:forEach var="mb" items="${mbtk}">
                   <option value="${mb.id}">
                   ${mb.name}
                   </option>
                   </c:forEach>
                 </select>
            	
            	</div></div>
            </td>            
        </tr>
        <tr>
        	<td colspan="6">
        	<table id="httk" cellpadding="0" cellspacing="0" border="0" class="content1">
        	</table>
        	<input type="hidden" id="tkjson" name="tkjson">
        	</td>
        </tr>
        <tr>
        <td colspan="6">
        <table  cellpadding="0" cellspacing="0" style="width:100%" class="content_gridview" border="1">
        <thead>        
            <tr>                
                <th colspan="2">出卖人(销方)</th>
                <th colspan="2">买受人（购方）</th>                
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
<table id="sjsdnr" cellpadding="0" cellspacing="0" border="0" class="content1" >
       <tr>
        	<td> 
            	出卖人名称：
            </td>
            <td>
            	<input id="qiymc" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
       
        <tr>
        	<td> 
            	住 所: 
            </td>
            <td>
            	<input id="chumdwdz" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	法定代表人: 
            </td>
            <td>
            	<input id="chumdwfddbr" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	委托代理人: 
            </td>
            <td>
            	<input id="chumdwwtdlr" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	电 话: 
            </td>
            <td>
            	<input id="chumdwdh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	传真: 
            </td>
            <td>
            	<input id="chumdwcz" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	邮政编码: 
            </td>
            <td>
            	<input id="chumdwyzbm" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	开户银行: 
            </td>
            <td>
            	<input id="chumdwkhyh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>        
        <tr>
        	<td> 
            	帐号: 
            </td>
            <td>
            	<input id="chumdwzh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	纳税人登记号: 
            </td>
            <td>
            	<input id="chumdwnsrdjh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
       
</table>
</td>
                <td><table id="sjsdnr1" cellpadding="0" cellspacing="0" border="0" class="content1" >
       <tr>
        	<td> 
            	出卖人结算单位名称：
            </td>
            <td>            	
                <input id="cmdwjsrmc" type="text" class="longtextbox1" readOnly="true">
            </td>           
        </tr>
        
        <tr>
        	<td> 
            	住 所: 
            </td>
            <td>
            	<input id="szs" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	法定代表人: 
            </td>
            <td>
            	<input id="sfddbr" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	委托代理人: 
            </td>
            <td>
            	<input id="swtdlr" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	电 话: 
            </td>
            <td>
            	<input id="sdh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	传真: 
            </td>
            <td>
            	<input id="scz" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	邮政编码: 
            </td>
            <td>
            	<input id="syb" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	开户银行: 
            </td>
            <td>
            	<input id="skhyh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>        
        <tr>
        	<td> 
            	帐号: 
            </td>
            <td>
            	<input id="szh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	纳税人登记号: 
            </td>
            <td>
            	<input id="sdjh" type="text" class="longtextbox1" readOnly="true" /> 
            </td>           
        </tr>
        
</table></td>
                <td><table id="bjsdnr" cellpadding="0" cellspacing="0" border="0" class="content1" >
       <tr>
        	<td>  
            	买受人名称： 
            </td>
            <td>
            	<input  id="maisr" type="text"  class="longtextbox" readonly/> 
            </td>           
        </tr>
       
        <tr>
        	<td> 
            	住 所: 
            </td>
            <td>
            	<input id="zs" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	法定代表人: 
            </td>
            <td>
            	<input id="fddbr" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	委托代理人: 
            </td>
            <td>
            	<input id="wtdlr" type="text" class="longtextbox" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	电 话: 
            </td>
            <td>
            	<input id="dh" type="text" class="longtextbox" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	传真: 
            </td>
            <td>
            	<input id="cz" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	邮政编码: 
            </td>
            <td>
            	<input id="yb" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	开户银行: 
            </td>
            <td>
            	<input id="khyh" type="text" class="longtextbox" /> 
            </td>           
        </tr>        
        <tr>
        	<td> 
            	帐号: 
            </td>
            <td>
            	<input id="zh" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	纳税人登记号: 
            </td>
            <td>
            	<input id="djh" type="text" class="longtextbox" /> 
            </td>           
        </tr>
       
</table></td>
                <td><table id="bjsdnr1" cellpadding="0" cellspacing="0" border="0" class="content1" >
       <tr>
        	<td>  
            	买受人结算单位名称：<span style="color: red;font-size:16px;vertical-align:middle;">*</span> 
            </td>
            <td>            	
                <div class="select"><div>
            	<select style="width:180px;" id="maisdwjsrbm" name="jsdw" style="width:100px;" onchange="changeTabForJsdw(this.value,'0')" ></select>            	
            	</div></div>
            </td>           
        </tr>
        
        <tr>
        	<td> 
            	住 所: 
            </td>
            <td>
            	<input id="bzs" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	法定代表人: 
            </td>
            <td>
            	<input id="bfddbr" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	委托代理人: 
            </td>
            <td>
            	<input id="bwtdlr" type="text" class="longtextbox" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	电 话: 
            </td>
            <td>
            	<input id="bdh" type="text" class="longtextbox" /> 
            </td>           
        </tr>
         <tr>
        	<td> 
            	传真: 
            </td>
            <td>
            	<input id="bcz" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	邮政编码: 
            </td>
            <td>
            	<input id="byb" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	开户银行: 
            </td>
            <td>
            	<input id="bkhyh" type="text" class="longtextbox" /> 
            </td>           
        </tr>        
        <tr>
        	<td> 
            	帐号: 
            </td>
            <td>
            	<input id="bzh" type="text" class="longtextbox" /> 
            </td>           
        </tr>
        <tr>
        	<td> 
            	纳税人登记号: 
            </td>
            <td>
            	<input id="bdjh" type="text" class="longtextbox" /> 
            </td>           
        </tr>
       
</table></td>				
            </tr>
        </tbody>
    </table>
        
        
        </td>
        
        </tr>
        <tr>
        <td colspan="4"><font size="2" color="#FF0000"><br></font></td>
        <td align="right">        
        <font size="2" >年度：</font>         
        </td>
        <td align="center">        
        <div class="select"><div>
            	<select style="width:70px;" id="nianf" name="nianf" onchange="changeTabForYxq(this.value)" >
            	<option value="2013">2013年</option>
            	<option value="2014" selected>2014年</option>
            	<option value="2015">2015年</option>
            	</select>            	
        </div></div>
        <font size="2">合同有效期：<input id="kssj" type="text" name="kaissj" class="textbox" value="${currentDate}" readonly/> 至<input id="jssj" type="text" class="textbox" name="jiessj" value="${endDate}" readonly/></font></td>
        <input type="hidden" id="cDate" value="${currentDate}">
        <input type="hidden" id="eDate" value="${endDate}">        
        </tr>        
        <tr>
		    <td colspan="6" align="center">	
		    <input type="button" id="jsdnr1" value="隐藏">
		    <input type="button" id="jsdnr" value="展开">&nbsp;&nbsp;&nbsp;    
		    <input id="but1" type="button" name="" value="保存" />&nbsp;&nbsp;&nbsp;
		    <input id="but2" type="button" name="" value="保存并提报" />&nbsp;&nbsp;&nbsp;
		    <input id="but3" type="button" name="" value="关闭" onclick="window.returnValue=1;window.close();"/></td>            
        </tr>
  </table>  
</form>
</div> 
	


<div id="dialog-confirm" title="是否确认提交？"></div>

  </body>
</html>

